function fac(n)
{
    if (n == 0)
        return 1;
    return n * fac(n - 1);
}

function fib(n)
{
    if (n < 2)
        return n;
    return fib(n - 1) + fib(n - 2);
}

function F(n)
{
    if (n == 0)
        return 1;
    return n - M(F(n - 1));
}
 
function M(n)
{
    if (n == 0)
        return 0;
    return n - F(M(n - 1));
}

function ack(x, y)
{    
     if (x == 0)
        return y + 1;    
     else if (y == 0)
        return ack(x - 1, 1);    
     else
        return ack(x - 1, ack(x, y - 1));
}

function min(a, b)
{
    if (a < b)
        return a;
    return b;
}

function main(argc, argv)
{
    if (argc != 2)
    {
        println("Ocekavam cislo na prikazove radce!");
        return 1;
    }
    println("factorial(", argv[1], ") = ", fac(argv[1]));
    println("fibonacci(", argv[1], ") = ", fib(argv[1]));
    println("HofstadterF(", argv[1], ") = ", F(argv[1]));
    println("HofstadterM(", argv[1], ") = ", M(argv[1]));
    var x = min(argv[1], 3);
    println("ackermann(", x, ", ", x, ") = ", ack(x, x));
    return 0;
}
